home *** CD-ROM | disk | FTP | other *** search
/ Gekikoh Dennoh Club 1 / Gekikoh Dennoh Club Vol. 1 (Japan).7z / Gekikoh Dennoh Club Vol. 1 (Japan) (Track 1).bin / kowin / archive / apl / gv_sh10.lzh / gv_sh.c next >
C/C++ Source or Header  |  1995-02-21  |  4KB  |  188 lines

  1. /*
  2.     Copyright 1995 Ogasawara Hiroyuki(COR.)
  3. */
  4.  
  5. #include    <corlib.h>
  6. #include    <sys_doslib.h>
  7.  
  8. #include    "Sesse.inc"
  9.  
  10. #define        PROG        "GV_Sh v1.00"
  11.  
  12. #define        GVIEWWIN    "gview.win"
  13. #define        XSIZE        (80-6)
  14. #define        YSIZE        (42-12)
  15.  
  16. int        WindowHeapSize= 1024*0;
  17.  
  18. static void
  19. Error( msg )
  20. char    *msg;
  21. {
  22.     ConsoleOpen();
  23.     ConsolePrint( msg );
  24.     ConsolePrint( "\r\n" );
  25. }
  26.  
  27. static void
  28. WaitMark()
  29. {
  30.     MouseSetPattern( 1, &SessePattern, 7, 3 );
  31.     MS_SEL( 1 );
  32. }
  33.  
  34. static void
  35. MakeNewGWin( ng )
  36. UGraphic    *ng;
  37. {
  38.     EventInfo    info;
  39.     info.option= EventUser;
  40.     info.ComBuffer= ng;
  41.     info.ComData= UserGraphic;
  42.     PidSendEvent( GVIEWWIN, &info, TRUE );
  43.     MFREE( ng->buf );
  44. }
  45.  
  46. #if 0
  47. GV_Rot( gp )
  48. UGraphic    *gp;
  49. {
  50.     UGraphic    ng;
  51.     WaitMark();
  52.     if( gp->color == WindowAttrGraphic65536 ){
  53.         unsigned short    *str= MALLOC( gp->h*gp->v*2 ),
  54.                 *ptr= gp->buf;
  55.         int    x, y;
  56.         if( (int)(ng.buf= str) < 0 )
  57.             return    FALSE;
  58.         for( y= 0 ; y< gp->h ; y++ ){
  59.             for( x= gp->v-1 ; x >= 0 ; x-- )
  60.                 *str++= ptr[x*gp->h +y];
  61.         }
  62.     }else{
  63.         unsigned char    *str= MALLOC( gp->h*gp->v ),
  64.                 *ptr= (void*)gp->buf;
  65.         int    x, y;
  66.         if( (int)(ng.buf= (void*)str) < 0 )
  67.             return    FALSE;
  68.         for( y= 0 ; y< gp->h ; y++ ){
  69.             for( x= gp->v-1 ; x >= 0 ; x-- )
  70.                 *str++= ptr[x*gp->h +y];
  71.         }
  72.     }
  73.     ng.h= gp->v;
  74.     ng.v= gp->h;
  75.     MakeNewGWin( &ng, gp );
  76.     MS_SEL( 0 );
  77.     return    TRUE;
  78. }
  79. #endif
  80.  
  81. GV_ToUG( sp )
  82. Sheet    *sp;
  83. {
  84.     UGraphic    ng;
  85.     unsigned char    *str= MALLOC( sp->h*sp->v );
  86.     unsigned short    *ptr1= (void*)sp->buf1, *ptr2= (void*)sp->buf2;
  87.     int    x, y;
  88.     WaitMark();
  89.     if( (int)(ng.buf= (void*)str) < 0 ){
  90.         Error( "メモリが足りません" );
  91.         return    FALSE;
  92.     }
  93.     for( y= 0 ; y< sp->v ; y++ ){
  94.         for( x= 0 ; x < sp->hword ; x++ ){
  95.             unsigned short    a= *ptr1++,
  96.                     b= *ptr2++;
  97.             int    i, t= (x<<4)-sp->h, cc= t< 0 ? 16 : t;
  98.             for( i= 0 ; i< cc ; i++ ){
  99.                 unsigned short    c= 0;
  100.             /* 0, 14, 1, 15 */
  101.                 if( (short)a < 0 )
  102.                     c= 14;
  103.                 if( (short)b < 0 )
  104.                     c++;
  105.                 *str++= c;
  106.                 a+= a;
  107.                 b+= b;
  108.             }
  109.         }
  110.     }
  111.     ng.h= sp->h;
  112.     ng.v= sp->v;
  113.     ng.color= WindowAttrGraphic16;
  114.     ng.palet= NULL;
  115.     MakeNewGWin( &ng );
  116.     MS_SEL( 0 );
  117.     return    TRUE;
  118. }
  119.  
  120. static int
  121. EventExec( wp, info )
  122. WindowID    wp;
  123. EventInfo    *info;
  124. {
  125.     DrawBuf    dbuf[4];
  126.     switch( info->option ){
  127.         case EventOpen:
  128.             WindowSetEventAttr( wp,  EventOpenON|EventRedrawON
  129.                 |EventCloseON|EventMouseSwitchON|EventIconifyON
  130.                 |EventUserON );
  131.             WindowRedraw( wp );
  132.             return    TRUE;
  133.         case EventIconify:
  134.             IconEnt( wp, PROG, AttrDefault, 12 );
  135.             return    TRUE;
  136.         case EventRedraw:
  137.             DrawSetClear( dbuf, ColorGray );
  138.             DrawSetSymbol( dbuf+1, 3, 1, PROG, 9|4, 12 );
  139.             DrawSetSymbol( dbuf+2, 3,14, "[Sheet=>UG]", 9, 12 );
  140.             WindowDraw( wp, dbuf, 3 );
  141.             return    TRUE;
  142.         case EventClose:
  143.             WindowClose( wp );
  144.             WindowConnectionClose();
  145.             return    TRUE;
  146.         case EventUser:
  147.             switch( info->ComData ){
  148.             case UserGraphic:
  149.                 /*GV_ToSheet( info->ComBuffer );*/
  150.                 return    TRUE;
  151.             case UserSheet:
  152.                 GV_ToUG( info->ComBuffer );
  153.                 return    TRUE;
  154.             case UserString:
  155.             case UserPaste:
  156.             case UserStrings:
  157.                 break;
  158.             }
  159.             return    FALSE;
  160.  
  161.         case EventMouseSwitch:
  162.             if( info->LeftON ){
  163.                 ConsoleOpen();
  164.                 ConsolePrint(
  165. "\r\n" PROG " 1995 COR.\r\n"
  166. "-------------------------------------------------------------------------\r\n"
  167. "16色UserGraphic<=Sheet変換を行います。変換したデータは gview へ転送します\r\n"
  168. "-------------------------------------------------------------------------\r\n"
  169.                 );
  170.                 return    TRUE;
  171.             }
  172.             return    FALSE;
  173.     }
  174.     return    FALSE;
  175. }
  176.  
  177.  
  178. void
  179. WindowMain( argc, argv )
  180. char    **argv;
  181. {
  182.     int    x= 400, y= 0;
  183.     argc= AnalyzeArgs( argc, argv, &x, &y, NULL, NULL );
  184.     WindowTitleOpen( x, y, XSIZE, YSIZE, NULL, " ",
  185.                         Close|Push|Icon, EventExec );
  186. }
  187.  
  188.